
#ifndef RTREACTORNOTIFYPIPE_H
#define RTREACTORNOTIFYPIPE_H

//#ifndef RT_LINUX
//  #error ERROR: ReactorNotifyPipe only supports LINUX now!
//#endif // RT_LINUX

#include "RtPipe.h"
#include "RtReactorInterface.h"

class CRtReactorBase;

class CRtReactorNotifyPipe : public IRtEventHandler
{
public:
	CRtReactorNotifyPipe();
	virtual ~CRtReactorNotifyPipe();

	RtResult Open(CRtReactorBase *aReactor);
	RtResult Close();

	// interface IRtEventHandler
	virtual RT_HANDLE GetHandle() const ;
	virtual int OnInput(RT_HANDLE aFd = RT_INVALID_HANDLE);

	RtResult Notify(IRtEventHandler *aEh, IRtEventHandler::MASK aMask);
	
private:
	struct CBuffer
	{
		CBuffer(RT_HANDLE aFd = RT_INVALID_HANDLE,
			   IRtEventHandler::MASK aMask = IRtEventHandler::NULL_MASK)
			: m_Fd(aFd), m_Mask(aMask)
		{
		}

		RT_HANDLE m_Fd;
		IRtEventHandler::MASK m_Mask;
	};
	
	CRtPipe m_PipeNotify;
	CRtReactorBase *m_pReactor;
};

#endif // !RTREACTORNOTIFYPIPE_H
